package com.ruoyi.system.api.wrapper;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteSysMenuService;
import com.ruoyi.system.api.domain.SysMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 菜单权限微服务包装服务，对微服务接口进行了封装，直接返回需要的数据。
 *
 * @author ruoyi
 * @date 2023-04-27
 */
@Component
public class RemoteSysMenuWrapperService extends RemoteBaseWrapperService {

    @Autowired
    private RemoteSysMenuService remoteSysMenuService;

    /**
     * 查询菜单权限
     *
     * @param menuId 菜单权限主键
     * @return 菜单权限
     */
    public SysMenu selectSysMenuByMenuId(Long menuId) {
        R<SysMenu> result = remoteSysMenuService.selectSysMenuByMenuId(menuId, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 查询菜单权限列表
     *
     * @param sysMenu 菜单权限
     * @return 菜单权限集合
     */
    public List<SysMenu> selectSysMenuList(SysMenu sysMenu) {
        R<List<SysMenu>> result = remoteSysMenuService.selectSysMenuList(sysMenu, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 新增菜单权限
     *
     * @param sysMenu 菜单权限
     * @return 结果
     */
    public Integer insertSysMenu(SysMenu sysMenu) {
        R<Integer> result = remoteSysMenuService.insertSysMenu(sysMenu, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 修改菜单权限
     *
     * @param sysMenu 菜单权限
     * @return 结果
     */
    public Integer updateSysMenu(SysMenu sysMenu) {
        R<Integer> result = remoteSysMenuService.updateSysMenu(sysMenu, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 批量删除菜单权限
     *
     * @param menuIds 需要删除的菜单权限主键集合
     * @return 结果
     */
    public Integer deleteSysMenuByMenuIds(Long[] menuIds) {
        R<Integer> result = remoteSysMenuService.deleteSysMenuByMenuIds(menuIds, SecurityConstants.INNER);
        return processResult(result);
    }
}
